package com.xzit.servlet;

import com.xzit.domain.Student;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author haoranlu
 * @project IntelliJ IDEA
 */
public class JstlServlet extends HttpServlet {
    public  JstlServlet(){

    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("stuName");
        String sex = req.getParameter("sex");
        String age = req.getParameter("age");
        int ageInt = 10;
        if (age != null){
            ageInt = Integer.parseInt(age);
        }
        Student stu = new Student();
        stu.setStuName("name");
        stu.setSex(sex);
        stu.setAge(ageInt);
        req.setAttribute("student",stu);

        req.getRequestDispatcher("iftag.jsp").forward(req,resp);
    }
}
